package com.ratp.expertisetechnique;

import com.ratp.bean.Expertise;
import com.ratp.bean.UtilsBean;
import com.ratp.composants.CustomTextWatcher;

import android.app.Activity;
import android.os.Bundle;
import android.text.Editable;
import android.widget.EditText;
import android.widget.TextView;

public class SignalementNEngageantPasCarros extends Activity {
	private TextView editPosteCoduiteCarros1Pas;
	private TextView editSellerieCarrosPas;
	private TextView editEtatInterCarrosPas;
	private TextView editParBriseCarrosPas;
	private TextView editCarrosExtPas;

	/** Called when the activity is first created. */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.signalment_nengageant_pas_carros);
		initVariables();
		initEcouteurs();
	}

	private void initVariables() {
		 editPosteCoduiteCarros1Pas = (EditText) findViewById(R.id.editPosteCoduiteCarros1Pas);
		 editSellerieCarrosPas = (EditText) findViewById(R.id.editSellerieCarrosPas);
		 editEtatInterCarrosPas = (EditText) findViewById(R.id.editEtatInterCarrosPas);
		 editParBriseCarrosPas = (EditText) findViewById(R.id.editParBriseCarrosPas);
		 editCarrosExtPas = (EditText) findViewById(R.id.editCarrosExtPas);
		 
		 Expertise expertise = UtilsBean.getExpertiseInstance();

		 editPosteCoduiteCarros1Pas.setText(expertise.getPosteConduiteNengagePas());
		 editSellerieCarrosPas.setText(expertise.getSellerieNengagePas());
		 editEtatInterCarrosPas.setText(expertise.getEtatIntNengagePas());
		 editParBriseCarrosPas.setText(expertise.getPareBriseNengagePas());
		 editCarrosExtPas.setText(expertise.getCarrosExtNengagePas());
		
	}

	private void initEcouteurs() {

		editPosteCoduiteCarros1Pas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setPosteConduiteNengagePas(s.toString());
			}
		});
		editSellerieCarrosPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setSellerieNengagePas(s.toString());
			}
		});
		editEtatInterCarrosPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setEtatIntNengagePas(s.toString());
			}
		});
		editParBriseCarrosPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setPareBriseNengagePas(s.toString());
			}
		});
		editCarrosExtPas.addTextChangedListener(new CustomTextWatcher() {

			@Override
			public void afterTextChanged(Editable s) {
				UtilsBean.getExpertiseInstance().setCarrosExtNengagePas(s.toString());
			}
		});
	}
}
